# Maintainer: Muflone http://www.muflone.com/contacts/english/

pkgname=dbeaver-plugin-office
pkgver=1.1.137.202302060909
_featurever=1.1.136.202302060909
_uiver=1.0.24.202302060909
pkgrel=1
pkgdesc='DBeaver plugin to export data to Microsoft Office format'
arch=('any')
url='https://dbeaver.io/'
license=('Apache')
makedepends=('unzip')
depends=('dbeaver>=4.2.5' 'dbeaver-plugin-apache-poi')
source=("https://dbeaver.io/update/ce/latest/plugins/org.jkiss.dbeaver.data.office_${pkgver}.jar"
        "https://dbeaver.io/update/ce/latest/plugins/org.jkiss.dbeaver.data.office.ui_${_uiver}.jar"
        "https://dbeaver.io/update/ce/latest/features/org.jkiss.dbeaver.ext.office.feature_${_featurever}.jar"
        "${pkgname}.info")
sha256sums=('723cf37635d26bb849e207ad0e31f4a210dd76e9bcc9cdc14c4ef150c6fdbfee'
            'e8d307d15faeeffb695e5be05cccc4731774e1f45ebf900d3ff83941ad5f8c75'
            '4b97c1fa2bf1bff827df0d40f18a88a8938f0d55d59cc65f7141b4cb133018f8'
            'ba62c368912b3953ce969fe7823c751c499f77a58420e153380a3c7121778d0a')
noextract=("org.jkiss.dbeaver.data.office_${pkgver}.jar"
           "org.jkiss.dbeaver.ext.office.feature_${_featurever}.jar")

package() {
  # Install plugin
  install -m 755 -d "${pkgdir}/usr/lib/dbeaver/plugins"
  install -m 644 -t "${pkgdir}/usr/lib/dbeaver/plugins" \
    "org.jkiss.dbeaver.data.office_${pkgver}.jar" \
    "org.jkiss.dbeaver.data.office.ui_${_uiver}.jar"

  # Extract feature
  install -m 755 -d "${pkgdir}/usr/share/dbeaver/features/org.jkiss.dbeaver.ext.office.feature_${_featurever}"
  unzip -q "${srcdir}/org.jkiss.dbeaver.ext.office.feature_${_featurever}.jar" \
        -d "${pkgdir}/usr/share/dbeaver/features/org.jkiss.dbeaver.ext.office.feature_${_featurever}"

  # Add configuration file (handled by the hook)
  install -m 755 -d "${pkgdir}/etc/dbeaver/bundles.d"
  install -m 644 "${srcdir}/${pkgname}.info" "${pkgdir}/etc/dbeaver/bundles.d/20-${pkgname}.info"
}
